package com.util;

import com.po.Admininfo;
import com.po.Buyerinfo;
import com.po.Sellerinfo;

import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.Date;

public class MyUtil {
    //获取时间字符串
    public static String getStringID(){
        String id=null;
        Date date=new Date();
        SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddHHmmssSSS");
        id=sdf.format(date);
        return id;
    }
    /**
     * 获得admin用户ID
     */
    public static Integer getAdminId(HttpSession session) {
        Admininfo admin = (Admininfo)session.getAttribute("admin");
        return admin.getA_id();
    }
    /**
     * 获得buyer用户ID
     */
    public static Integer getBuyerId(HttpSession session) {
        Buyerinfo buyer = (Buyerinfo)session.getAttribute("buyer");
        return buyer.getB_id();
    }
    /**
     * 获得seller用户ID
     */
    public static Integer getSellerId(HttpSession session) {
        Sellerinfo seller = ( Sellerinfo)session.getAttribute("seller");
        return seller.getS_id();
    }

}
